home *** CD-ROM | disk | FTP | other *** search
/ Trusted Irix /B 4.0.4 / Trusted-Irix B-4.0.1.iso / dist / eoe1.idb / usr / include / sys / quota.h.z / quota.h
C/C++ Source or Header  |  1992-04-03  |  6KB  |  145 lines

  1. #ifndef __SYS_QUOTA_H__
  2. #define __SYS_QUOTA_H__
  3.  
  4. /**************************************************************************
  5.  *                                      *
  6.  *          Copyright (C) 1989, Silicon Graphics, Inc.          *
  7.  *                                      *
  8.  *  These coded instructions, statements, and computer programs  contain  *
  9.  *  unpublished  proprietary  information of Silicon Graphics, Inc., and  *
  10.  *  are protected by Federal copyright law.  They  may  not be disclosed  *
  11.  *  to  third  parties  or copied or duplicated in any form, in whole or  *
  12.  *  in part, without the prior written consent of Silicon Graphics, Inc.  *
  13.  *                                      *
  14.  **************************************************************************/
  15.  
  16. /*
  17.  * Various junk to do with various quotas (etc) imposed upon
  18.  * the average user (big brother finally hits UNIX).
  19.  */
  20.  
  21. /*
  22.  * The following constants define the default amount of time given a user
  23.  * before the soft limits are treated as hard limits (usually resulting
  24.  * in an allocation failure). These may be  modified by the quotactl
  25.  * system call with the Q_SETQLIM or Q_SETQUOTA commands.
  26.  */
  27.  
  28. #define    DQ_FTIMELIMIT    (7 * 24*60*60)        /* 1 week */
  29. #define    DQ_BTIMELIMIT    (7 * 24*60*60)        /* 1 week */
  30.  
  31. /*
  32.  * There is one quota file per file system and the dqblk structure
  33.  * defines the format of an entry for one user in the disk quota file
  34.  * (as it appears on disk). This index into the file for a particular uid
  35.  * is calculated by qt_dqoff(). This had to change from Berkeley/Sun's 
  36.  * implementation since EFS does not support holes in files.
  37.  * In the kernel, we keep track of the quotas in basic blocks (512 bytes),
  38.  * All user commands obtain numbers in bbs from the kernel, but display 
  39.  * and manipulate figures in kbytes.
  40.  */
  41.  
  42. struct    dqblk {
  43.     u_long    dqb_bhardlimit;    /* absolute limit on disk blks alloc */
  44.     u_long    dqb_bsoftlimit;    /* preferred limit on disk blks */
  45.     u_long    dqb_curblocks;    /* current block count */
  46.     u_long    dqb_fhardlimit;    /* maximum # allocated files + 1 */
  47.     u_long    dqb_fsoftlimit;    /* preferred file limit */
  48.     u_long    dqb_curfiles;    /* current # allocated files */
  49.     u_long    dqb_btimelimit;    /* timer when usage exceeds disk blks limit */
  50.     u_long    dqb_ftimelimit;    /* timer when usage exceeds file limit */
  51. };
  52.  
  53. /*
  54.  * Definitions for the 'quotactl' system call.
  55.  */
  56. #define Q_QUOTAON    1    /* turn quotas on */
  57. #define Q_QUOTAOFF    2    /* turn quotas off */
  58. #define Q_SETQUOTA    3    /* set disk limits & usage */
  59. #define Q_GETQUOTA    4    /* get disk limits & usage */
  60. #define Q_SETQLIM    5    /* set disk limits only */
  61. #define Q_SYNC        6    /* update disk copy of quota usages */
  62. #define Q_ACTIVATE    7    /* update quotas without enabling */
  63.  
  64. /*
  65.  * The quota file has a header, followed by an index
  66.  * (list of uids), followed by the on-disk quota information which is
  67.  * kept for those users that have quotas. The index size lies in the range
  68.  * Q_MININDEX-Q_MAXINDEX. The header has a magic number, followed by the
  69.  * quota file index size and then the number of users whose uids appear
  70.  * in the index.
  71.  */
  72. struct qt_header {
  73.     u_short qh_magic;    /* quota file magic number */
  74.     u_short qh_index;    /* quota file index size */
  75.     u_short qh_nusers;    /* number of users in this quota file */
  76.     u_short qh_uid[1];    /* list of uid's. 0 is always the first one */
  77. };
  78. #define Q_HEADER    (sizeof(struct qt_header)-sizeof(u_short))
  79. #define Q_MININDEX    4096        /* min index size for quotas file */
  80. #define Q_MAXINDEX    4096*10        /* max index size for quotas file */
  81. #define Q_MAGIC        0x8765        /* magic number */
  82. #define Q_MAXUSERS    ((Q_MAXINDEX - Q_HEADER)/sizeof(u_short))
  83.  
  84.  
  85. #ifndef _KERNEL
  86. extern int quotactl(int, caddr_t , int, caddr_t);
  87. #endif /* !_KERNEL */
  88.  
  89. #ifdef _KERNEL
  90. /*
  91.  * The incore dquot structure records disk usage for a user on a filesystem.
  92.  * A cache is kept of recently used entries. Active inodes with quotas
  93.  * associated with them have a pointer to a incore dquot structure.
  94.  */
  95. struct    dquot {
  96.     struct    dquot *dq_forw, *dq_back;/* hash list, MUST be first entry */
  97.     struct    dquot *dq_freef, *dq_freeb; /* free list */
  98.     u_short    dq_flags;
  99. #define    DQ_MOD        0x01    /* this quota modified since read */
  100.     u_short    dq_cnt;        /* count of active references */
  101.     u_short    dq_uid;        /* user this applies to */
  102.     ulong dq_off;        /* offset into quotas file */
  103.     struct mount *dq_mp;    /* filesystem this relates to */
  104.     struct dqblk dq_dqb;    /* actual usage & quotas */
  105.     sema_t dq_sema;        /* semaphore for quota lock */
  106. };
  107.  
  108. #define    dq_bhardlimit    dq_dqb.dqb_bhardlimit
  109. #define    dq_bsoftlimit    dq_dqb.dqb_bsoftlimit
  110. #define    dq_curblocks    dq_dqb.dqb_curblocks
  111. #define    dq_fhardlimit    dq_dqb.dqb_fhardlimit
  112. #define    dq_fsoftlimit    dq_dqb.dqb_fsoftlimit
  113. #define    dq_curfiles    dq_dqb.dqb_curfiles
  114. #define    dq_btimelimit    dq_dqb.dqb_btimelimit
  115. #define    dq_ftimelimit    dq_dqb.dqb_ftimelimit
  116.  
  117. extern struct dquot *qt_getinoquota(struct inode *ip);
  118. extern int qt_chkdq(struct inode *ip, long change, int force, int *spaceleft);
  119. extern int qt_chkiq(struct mount *mp, struct inode *ip, u_int uid, int force);
  120. extern void qt_dqrele(struct dquot *dqp);
  121. extern int qt_closedq(struct mount *mp, int umounting);
  122. extern void qt_dqput(struct dquot *dqp);
  123. extern void qt_dqupdate(struct dquot *dqp);
  124. extern void qt_dqinval(struct dquot *dqp);
  125. extern int qt_getdiskquota(u_int uid, struct mount *mp, int allocate,
  126.     struct dquot **dqpp);
  127.  
  128. extern struct dquot dqfreelist;        /* start of the free list */
  129. extern struct dquot *dquot;        /* start of the incore quota table */
  130.  
  131. #define qfree_sema (dqfreelist.dq_sema)
  132.  
  133. #define DQLOCK(dqp) { \
  134.     psema(&(dqp)->dq_sema, PZERO); \
  135.     ASSERT(valusema(&(dqp)->dq_sema) <= 0); \
  136. }
  137.  
  138. #define DQUNLOCK(dqp) { \
  139.     ASSERT(valusema(&(dqp)->dq_sema) <= 0); \
  140.     vsema(&(dqp)->dq_sema); \
  141. }
  142. #endif /* _KERNEL */
  143.  
  144. #endif /* __SYS_QUOTA_H__ */
  145.